<template>
    <el-carousel :interval="4000" :height="sumHeight">
        <el-carousel-item v-for="item, index in imgList" :key="index">
            <div class="divs" v-for="double, index in item" :key="index">
                <div
                    style="margin:0 auto;width: 60px;height: 93%;background-color: #fff;border: 1px solid red;"
                >
                    <img
                        :src="double.imgUrl"
                        style="width:100%;height:100%;"
                        @click="$emit('callBack', double.imgUrl)"
                    />
                </div>
            </div>
        </el-carousel-item>
    </el-carousel>
</template>

<script lang='ts'>
type ListType = Array<{ imgUrl: string }>
import { defineComponent, computed } from 'vue'
export default defineComponent({
    name: 'Carousel',
    setup(props) {
        const imgList = computed((): Array<ListType> => {
            let Data = props.imgData
            let reault: Array<ListType> = []
            if (Data instanceof Array) {
                Data.reduce<ListType>((sum, value) => {
                    if (sum.length >= 3) {
                        reault.push(sum)
                        sum = []
                    }
                    sum.push(value)
                    return sum
                }, [])
            }
            return reault
        })
        return { imgList }
    },
    props: ['sumHeight', 'imgData'],
    emits: ["callBack"]
})
</script>
<style scoped>
.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 100px;
    margin: 0;
    text-align: center;
}

.divs {
    width: 33.3%;
    height: 100%;
    float: left;
}

>>> .el-carousel__button {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: none;
}
</style>